草庐IT

firebase - Firestore : how to make query where field is null

全部标签

javascript - 在没有 transaction.get() 的情况下启动 firestore 事务

我想将文档从一个集合移动到另一个集合。因此,我想使用事务来1.创建新文档和2.删除旧文档。我可以执行以下操作:db.runTransaction((transaction)=>{returntransaction.get(docRef).then(()=>transaction.set(newDocRef.doc(docId),doc)).then(()=>transaction.delete(docRef));我如何重写此代码以从transaction.set()而不是transaction.get()开始,因为我已经有了这个上下文中的文档,所以它是多余的。区别在于transacti

javascript - Firebase 函数不记录 "console.log()"语句

我一直在为下面的函数而苦苦挣扎,它的console.log()语句没有出现在Firebase日志中。如果我删除所有以db.collection调用开头的内容,顶部的console.log()语句就会显示出来,但是一旦我添加了db.collection调用,没有console.log()语句出现在Firebase的日志中。我对JavaScript不是很熟悉(我通常使用Python进行后端编程),所以这可能是Promises工作方式的问题。我现在正在研究这个。知道发生了什么吗?exports.purchaseItem=functions.https.onCall((data,context

firebase - Sec-Fetch-Mode 而不是 Preflight

我创建了登录FE并完成了它。和往常一样,我的ajaxgoto是Axios。我的代码如下。constbaseUrl=http://localhost:5000/project/us-central1/apiAxios.post(`${baseUrl}/v1/user/login`,{...data},{headers:{Authorization:'Basicauth...'}},).then(r=>console.log(r).catch(e=>console.log(e));现在,当我尝试向我的本地firebase云函数发送请求时。我收到400错误请求。检查请求后,我想知道为什么它没

javascript - Firebase child_added 没有先加载所有数据

我有一个应用程序,我想在其中加载一些初始数据(使用Firebase.once('value')完成),然后在稍后的某个时候我想接收事件已添加到该Firebase引用的子节点的数量。为此,我想使用Firebase.on('child_added'),但根据定义(并在实践中看到),它首先加载该Firebase引用中的所有数据.有没有办法绕过这种行为,只监听child_added事件。此外,像转储初始数据集这样的变通方法并不是解决方案(想象一个包含超过一百万个数据点的数据集-我不想每个数据点都只是为了在添加一个数据点时监听!)。编辑:Firebase.on('child_added')可以与

javascript - 直接在 on() 回调中使用 off() Firebase?

假设我有一个一次性手术。喜欢删除。varq=ref.child('users').child(targetUserId).child('chat');q.on('child_added',function(obj){obj.ref().remove();//Thisworksright?q.off();});我可以在on()回调中直接执行off()吗?我不需要指定eventType对吗?没有别的要清理了吧?Fromthedocs:同样,如果没有指定事件类型或回调,则引用的所有回调都将被删除。 最佳答案 CanIexecuteoff(

javascript - 如何将函数外部的变量传递给 firebase 事件

下面是我在nodeJS服务器上运行的代码,我正在尝试sendanSMSmessage一旦'child_added'事件被触发//TwilioCredentialsvaraccountSid='';varauthToken='';vartwilio=require("twilio");varclient=newtwilio.RestClient(accountSid,authToken);//TWILIOFunctionclient.messages.create({to:"+12432056980",//Thisneedtobeobtainedfromfirebasefrom:"+14

javascript - 如何使用 Node.js、Angular.js 和 Firebase 实现无限滚动?

更新8:代码:varconfig={info};firebase.initializeApp(config);varfb=firebase.database().ref("posts/fun");varapp=angular.module('app',['firebase']);app.controller('ctrl',function($scope,$firebaseArray,$timeout){$scope.data=[];var_start=0;var_end=4;var_n=5;$scope.getDataset=function(){fb.orderByChild('id

javascript - 使用 firebase 的网络谷歌身份验证

uncaughtexception:Error:Thisoperationisnotsupportedintheenvironmentthisapplicationisrunningon."location.protocol"mustbehttp,httpsorchrome-extensionandwebstoragemustbeenabled.varconfig={apiKey:"*****",authDomain:"******",};firebase.initializeApp(config);varprovider=newfirebase.auth.GoogleAuthProv

javascript - 在 firebase 中 - 如何在服务器上生成 idToken 以进行测试?

我想测试一个创建用户的云函数。在正常情况下,我在浏览器中生成一个idToken并通过header将其发送到服务器:Authorization:BeareretcIdToken但是我想在没有浏览器的情况下测试这个功能。在我的摩卡测试中,我有:before(done=>{firebase=requirefirebase..--thisissupposetobelikethebrowserlib.admin=requireadmin..idToken=null;uid="AY8HrgYIeuQswolbLl53pjdJw8b2";admin.auth().createCustomToken(

javascript - 云函数 : How to copy Firestore Collection to a new document?

我想在发生事件时使用CloudFunctions在Firestore中制作一个集合的副本我已经有了迭代集合并复制每个文档的代码constfirestore=admin.firestore()firestore.collection("products").get().then(query=>{query.forEach(function(doc){varpromise=firestore.collection(uid).doc(doc.data().barcode).set(doc.data());});});有更短的版本吗?一次复制整个集合? 最佳答案